# 欢迎来到答题比赛
from functools import total_ordering

queions, answer = "1+1", "2"
queions2, answer2 = "2+3", "5"
questions3, answer3 = "3+4", "7"
# 最大尝试次数
max_tries = 3
# 总关卡
total_levels = 3
# 是否在游戏状态
is_playing = True

for level in range(1, total_levels + 1):
    # 打印当前第几关
    print(f"------第{level}关开始了-----------")
    # 取出关卡的题目问题
    if level == 1:
        queions, answer = "1+1", "2"
    elif level == 2:
        queions, answer = "2+3", "5"
    else:
        queions, answer = "4+3", "7"

    trice = 1

    while trice <= max_tries:
        # 开始提问
        user_input = input(f"问题是{queions}")

        if user_input == answer:
            print("回答正确")
            break
        elif user_input == '':
            print("不能打印空")
            continue
        elif user_input == 'q':#直接退出比赛，要设置一个变量来控制游戏状态
            print("程序退出")
            is_playing = False
            break
        else:
            print(f"回答错误还有{3 - trice}次机会")
        trice += 1

    if is_playing == False:
        print("非常遗憾退出了")
        break
    if is_playing == True:
        print("恭喜过关了")